import React, { Component } from 'react';
import { Button } from 'antd';
import styles from '../../../index.less';

class TabSystemComponent extends Component {
  constructor(props) {
    super(props);
    this.state = {
      disabled: props.disabled,
      data: [{
        sName: '最大整数',
        value: '最大整数(变量,0)',
      }, {
        sName: '四舍五入',
        value: '四舍五入(变量,0)',
      }, {
        sName: '最小整数',
        value: '最小整数(变量,0)',
      }],
    };
  }

  componentWillReceiveProps(nextProps) {
    this.setState({ disabled: nextProps.disabled });
  }


  handleDoubleClick = (e, child) => {
    this.props.onChangeFormnula(child.value);
  }

  render() {
    const { data, disabled } = this.state;
    return (
      <div className={styles.tabButton}>
        {
          data.map(child =>
            (
              <Button
                key={child.value}
                disabled={disabled}
                onDoubleClick={e => this.handleDoubleClick(e, child)}
              >
                {child.sName}
              </Button>
            ))
        }
      </div>
    );
  }
}

export default TabSystemComponent;
